<!--更新资料-->

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	    <link rel="stylesheet" href="/static/css/backstage/amazeui.min.css" >
		<link rel="stylesheet" href="/static/css/backstage/admin.css" >
		<link rel="stylesheet" href="/static/css/backstage/app.css" >
		<style>
			.admin-main{
				padding-top: 0px;
			}
			.error{
				color:red;
			}
			.success{
				color:#5eb95e;
			}
		</style>
	</head>
	<body>
		<div class="am-cf admin-main">
		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				<div class="am-g">
					<form class="am-form am-form-horizontal"	 name="myform" id="myform" action="/backstage/doUpdateInfo" method="post"	style="padding-top:30px;" data-am-validator>
						<input type="hidden" name="_method" value="PUT" />
                        <input name="a_id" type="hidden" value="${admin_name.a_id}">
						<div class="am-form-group">
							<label for="user-name" class="am-u-sm-3 am-form-label">
							用户名 </label>
							<div class="am-u-sm-9">
								<input type="text" onBlur="checkUserName()" id="userName" value="${admin_name.a_username}" required placeholder="请输入用户名" name="username">
								<small id="nameErr">输入用户名。</small>
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-name" class="am-u-sm-3 am-form-label">
								真实姓名</label>
							<div class="am-u-sm-9">
								<input style="background:none;" type="text" id="doc-vld-pwd-2" value="${admin_name.a_realname}" required placeholder="真实姓名"
									name="realname" readonly data-equal-to="#doc-vld-pwd-1"  required> <small>真实姓名（不可改）。</small>
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-name" class="am-u-sm-3 am-form-label">
								手机号 </label>
							<div class="am-u-sm-9">
								<input type="text" value="${admin_name.a_phone}" required placeholder="请输入手机号" onBlur="checkPhone()" id="phone" name="phone">
								<small id="phoneErr">输入手机号。</small>
								<a href="updatePwd" class="am-text-danger updatepwd" style="float: right;">修改密码>></a>
							</div>
						</div>
						<div class="am-form-group">
							<div class="am-u-sm-9 am-u-sm-push-3">
								<input type="button" class="am-btn am-btn-success updatebtn" value="修改资料" />
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript" src="/static/js/backstage/jquery-1.8.3.js" ></script>
	<script type="text/javascript" src="/static/js/backstage/plugs.js" ></script>
	<!--<script>-->
		<!--$(".updatepwd").click(function() {-->
			<!--window.parent.$.jq_Panel({-->
				<!--title: "修改密码",-->
				<!--iframeWidth: 500,-->
				<!--iframeHeight: 300,-->
				<!--url: "backstage/updatePwd"-->
			<!--});-->
		<!--});-->
	<!--</script>-->
		<script type="text/javascript">
                function checkUserName(){
                    var username = document.getElementById('userName');
                    var errname = document.getElementById('nameErr');
                    var pattern = /^[\w\u4E00-\u9FA5]{3,}$/;  //用户名格式正则表达式：用户名要至少三位
                    if(username.value.length == 0){
                        errname.innerHTML="用户名不能为空";
                        errname.className="error";
                        return false;
                    }
                    if(!pattern.test(username.value)){
                        errname.innerHTML="用户名为3位以上的字母、数字、下划线组合";
                        errname.className="error";
                        return false;
                    }
                    else{
                        errname.innerHTML="OK";
                        errname.className="success";
                        return true;
                    }
                }

				//验证手机号
                function checkPhone(){
                    var phone = document.getElementById('phone');
                    var errname = document.getElementById('phoneErr');
                    var pattern = /^1[3|4|5|7|8][0-9]{9}$/;
                    if(phone.value.length == 0){
                        errname.innerHTML="手机号不能为空";
                        errname.className="error";
                        return false;
                    }
                    if(!pattern.test(phone.value)){
                        errname.innerHTML="手机号不合规范";
                        errname.className="error";
                        return false;
                    }
                    else{
                        errname.innerHTML="OK";
                        errname.className="success";
                        return true;
                    }
                }


                $(".updatebtn").click(function(){
                	if(checkUserName()&&checkPhone())
                	{
						$.ajax({
							url:"/backstage/doUpdateInfo",
							dataType:"json",
							type:"put",
							data:$("#myform").serialize(),
							success:function(result){
								<!--console.log(result);-->
								alert(result.tips);
								window.location.href=location.href;
							},
							error:function(result){
              				  	alert("系统繁忙！");
           					 }
						});
					}
                		<!--myform.submit();-->
                });

    </script>
	</body>
</html>
